<template>
	<view class="content">
		<view class="section" @click="goWithdraw(1)">
			<view class="title">
				提现金额
			</view>
			<view class="sec_center">
				<text class="sec_text">￥</text>
				<input placeholder="请输入您要提现的金额" v-model="money" type="number"/>
				<view class="sec_btn flexs" @click="allwall">
					全部提现
				</view>
			</view>
			<view class="sec_foot">
				<text>可提现余额￥{{walletdata.money}}</text>
				<text>提示:需收取{{walletdata.trate}}%的手续费</text>
			</view>
		</view>
		<view class="tixianbtn" @click="submit">提现</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			infodata:{},
			ptype:2,//1支付宝2微信3银行卡
			money:"",
			walletdata:{
				money:0,
				tnum:0,
				trate:0
			}
		};
	},
	onLoad() {
		this.infodata = uni.getStorageSync("infodata")
	},
	onShow() {
		this.getTixianindex()
	},
	methods:{
		getTixianindex(){
			this.$Request.get(this.$api.user.withdrawalindex).then(res => {
				this.walletdata = res.data
			});
		},
		allwall(){
			this.money = this.walletdata.money
		},
		submit(){
			if (!this.money) {
				uni.showToast({
					title: '请输入金额',
					icon: 'none'
				});
				return;
			}
			if (Number(this.money) <  Number(this.walletdata.tnum)) {
				uni.showToast({
					title: '最低提现金额为' + this.walletdata.tnum,
					icon: 'none'
				});
				return;
			}
			let data = {
				money: this.money,
				ptype: this.ptype,
				name: this.infodata.name,
				qcode: this.infodata.fileUrl
			};
			this.$Request.post(this.$api.user.submit, data).then(res => {
				uni.showToast({
					title:res.msg,
					icon:"none"
				})
				setTimeout(()=>{
					uni.navigateBack({
						delta:2
					})
				},800)
				 clearTimeout();
			});
		},
		goWithdraw(checktype){
			uni.navigateTo({
				url:"/pages/center/withdrawal/binding?checktype=" + checktype
			})
		}
	}
};
</script>

<style lang="scss" scoped>
	.content{
		min-height: 100vh;
		background: #FFFFFF;
		padding-top: 20rpx;
		.tixianbtn {
			width: 710rpx;
			height: 88rpx;
			background: linear-gradient(90deg, #6ce281 0%, #33d29c 100%);
			border-radius: 100rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			margin: 300rpx auto;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #ffffff;
		}
		.section{
			width: 709rpx;
			height: 406rpx;
			background: #FFFFFF;
			box-shadow: 0px 3px 6px rgba(13, 107, 107, 0.16);
			border-radius: 10rpx;
			margin: 0 auto;
			padding: 20rpx;
			margin-bottom: 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			.sec_foot{
				display: flex;
				flex-direction: column;
				text{
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #333333;
				}
			}
			.sec_center{
				display: flex;
				align-items: center;
				justify-content: space-around;
				.sec_btn{
					width: 145rpx;
					height: 67rpx;
					background: #FC5F5F;
					border-radius: 10rpx;
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
				}
				input{
					width: 400rpx;
					height: 67rpx;
					background: #FFFFFF;
					border: 1px solid #E4E4E4;
					border-radius: 10rpx;
					padding-left: 20rpx;
					box-sizing: border-box;
				}
				.sec_text{
					font-size: 80rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #333333;
				}
			}
			.title{
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
			}
		}
	}
</style>
